package com.zhang;

import com.zhang.domain.User;
import com.zhang.mapper.UserMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;

@SpringBootTest
public class Add {



    @Autowired
    private UserMapper userMapper;


    //1.插入 (插入后会将自增id回填到user对象中 ,前提: 配置了@TableId(type = IdType.AUTO)
    @Test
    public void contextLoads() {
        User user = new User();
        user.setUsername("阅阅妹");
        user.setPassword("123");
        user.setBirthday(new Date());


        int row = userMapper.insert(user);
        System.out.println("受影响的行数:"+row);
        System.out.println("自增id:"+user.getId());
    }



}
